import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'

export const PushFlowType = async ({ url, OptionsEvent, ClientData }) => {
    let data = {
        type: '预警管理',
        pageSize: 10,
        params: { pageIndex: 1 },
        // hideInSearch: true,
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [<AddDataButton OptionsEvent={OptionsEvent} url={url} type="primary" icon="add" title="新增类别" />],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '流程类别' },
            {
                dataIndex: 'templateId',
                title: '模板编号',
                rules: true,
                width: 200,
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'templateName',
                title: '模版名称',
                rules: true,
                width: 120,
                valueType: 'input',
            },
            {
                dataIndex: 'templateContent',
                title: '模板内容',
                rules: true,
                width: 200,
                valueType: 'input',
                ellipsis: true,
                hideInSearch: true,
                hideInTable: true,
            },
            {
                dataIndex: 'appId',
                title: '微信AppId',
                rules: true,
                valueType: 'input',
                width: 200,
                copyable: true,
            },
            {
                dataIndex: 'appSecret',
                title: '微信AppSecret',
                rules: true,
                valueType: 'input',
                width: 300,
                copyable: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'projectUuid',
                title: '项目名称',
                rules: true,
                width: 150,
                valueType: 'select',
                valueEnum: ClientData.project,
                hideInSearch: true,
            },
            {
                dataIndex: 'miniProgramUrl',
                title: '外连跳转的小程序地址',
                valueType: 'input',
                width: 200,
                ellipsis: true,
                hideInSearch: true,
            },
            // 通用部分
            { ...commonTableList.isEnabled, rules: true },
            { ...commonTableList.sortId, rules: true },
            { ...commonTableList.code, rules: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" url={url} data={record} />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="delete"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }
    return data
}
